<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>IQ TEST</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/bootstrap.css" media="screen">
    <link rel="stylesheet" href="css/bootswatch.min.css">
	<link rel="stylesheet" href="css/form_validation.css">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
	<script src="js/jquery-1.10.2.min.js"></script>
	<script src="js/jquery.validate.min.js" type="text/javascript"></script>
	<script src="js/bootstrap.min.js"></script>
    <script src="js/bootswatch.js"></script>
	<script type="text/javascript">
	$(document).ready(function () {
	
	//add method validate
	var respone;
	$.validator.addMethod("checkStudentID", function(value, element) {
	      $.ajax({
	          type: "POST",
	          url: "member/member_check_student_id.php",
	          data: ({ stucode:value }),
	          async: false,
	       success: function(result)
	       {
	          respone = result;
	       }
	     });
		  if(respone == 1)
		  {
		  	return true;
		  }  
		  else
		  {
		  	return false;
		  }
	}, "*ไม่พบข้อมูล");
	
	
	$("#infoForm").validate({
	   rules: {
			 stucode: {
					required: true,
					number: true,
					minlength: 7,
					maxlength: 7,
					checkStudentID: true
					}
		},
	   messages: {
			stucode: {
					required: "กรุณากรอกข้อมูล",
					number: "กรุณากรอกเฉพาะตัวเลขเท่านั้น",
					minlength: "กรุณาใส่ข้อมูลให้ถูกต้อง",
					maxlength: "กรุณาใส่ข้อมูลให้ถูกต้อง"
					}

	   }
	})
	});
	
	function resetForm()
	{
	$("#infoForm").reset();
	return false;
	}
	</script>
  </head>
  <body>
<?php include ("menu.php"); ?>
    <div class="container">  
      <!-- Forms
      ================================================== -->
      <div>
        <div class="row">
          <div class="col-lg-12">
            <div class="page-header">
              <h2 id="forms">ยินดีต้อนรับ</h2>
            </div>
          </div>
        </div>
        <div class="row">
            <div class="well bs-component">
              <form class="form-horizontal" id="infoForm" method="post" action="member/member_detail.php">
                <fieldset>
                  <legend>&nbsp;</legend>
				  <div class="form-group">
                    <label for="" class="col-lg-2 control-label">User ID: </label>
                    <div class="col-lg-10">
                      <input type="text" class="form-control" id="stucode" placeholder="User ID" name="stucode">
                    </div>
                  </div>
                  <div class="form-group">
                    <div class="col-lg-10 col-lg-offset-2">
                      <button type="submit" class="btn btn-primary">ยืนยัน</button>
					  <button class="btn btn-default" onclick="resetForm()">ยกเลิก</button>
                    </div>
                  </div>
                </fieldset>
              </form>
            </div>
        </div>
      </div>
      <footer>
        <div class="row">
          <div class="col-lg-12">
            <ul class="list-unstyled">
              <li class="pull-right"><a href="#top">Back to top</a></li>
            </ul>
          </div>
        </div>
      </footer>
    </div>
  </body>
</html>
